#include<stdio.h>
int f(int x,int y,int*k);
int main(){
	int i,n,j;
	scanf("%d",&n);
	int a[n],k[n];
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(i=0,j=0;i<n;i++){
		if(f(a[i],a[i+1],&k[j])){
					j+=2;
		}else{
			j++;
		}
		//a[i+1]=
	}
	if(f(6,7,&a[0])){
		printf("%d\n",a[0]);
	}
	printf("%d %d",a[0],a[1]);
	return 0;
} 
int f(int x,int y,int*k){
	int x1=x,y1=y;
	int kx=0,ky=0,ret=0;
	while(y!=1){
		if(y%2==0){
			y/=2;
		}else{
			y=(y*3+1)/2;
		}
		if(x==y){
			kx=1;break;
		}
	}
	y=y1;
	while(x!=1){
		if(x%2==0){
			x/=2;
		}else{
			x=(x*3+1)/2;
		}
		if(y==x){
			ky=1;break;
		}
	}
	printf("%d %d\n",kx,ky);
	if(kx==0&&ky==0){
		k[0]=x1;k[1]=y1;ret=1;
	}else if(kx==1){
		k[0]=y1;
	}else{
		k[0]=x1;
	}
	return ret;
}
